package models;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.*;
import play.data.validation.Required;
import play.db.jpa.Model;

/**
 * Log Entity, Used to create the log system that logs all activites done by
 * users in a certain organization to be viewed by the Organization lead
 * 
 * @author Mai Selwanes
 */
@Entity
public class Log extends Model {

	/**
	 * the log's Organization
	 */
	@Required
	@OneToOne
	public Organization organization;
	/**
	 * the User who performed the action
	 */
	@Required
	@ManyToOne 
	public User performer;
	/**
	 * the action made
	 */
	@Required
	public String action;
	/**
	 * the timing of the action
	 */
	@Required
	Date timing;

	/**
	 * Default constructor
	 * 
	 * @param organization
	 *            the the log's Organization
	 * @param performer
	 *            the User who performed the action
	 * @param action
	 *            the action made
	 */
	public Log(Organization organization, User performer, String action) {
		this.organization = organization;
		this.performer = performer;
		this.action = action;
		this.timing = new Date();
	}
	//
	// public static void main(String[]args)
	// {
	// User u= new User ("mai@","mai","pass",1, 100,true, true);
	// Organization o=new Organization ("organ","@@", "asjnck",
	// "descibe", "private");
	// Entities e= new Entities("entoti", false, o);
	// Topic t= new Topic ("scbjahbj", u, e, "toopicsi");
	// t.subscribers.add(u);
	// t.executeAndPromote(t);
	// Log l=Log.find("byorganization_name", "organ").first();
	// System.out.println (l.organization_name);

}
